<?php

require_once "spElement.php";

class spTextArea extends spElement
{
	public function __construct( $data=null )
	{
		parent::__construct( "textarea", $data );
		parent::setMustHaveEndingTag( true );

		if ( isset($data["name"]) )
			parent::addAttr ( "name", $data["name"] );

		if ( parent::getAttr( "rows" )==null )
			parent::addAttr( "rows", "4" );

		if ( parent::getAttr( "cols" )==null )
			parent::addAttr( "cols", "80" );

	}
	
	public function setElementDataString( $s )
	{
		parent::setElementDataString( $s );	
		parent::setContent( $s );
	}
	
	public function render()
	{
		if ( parent::readOnly() )
		{
			parent::addAttr( "readonly", "readonly" );
			//parent::addAttr( "disabled", "disabled" );
		}
		
		parent::render();
	}
	
	public function updateFromRequest()
	{
		parent::updateFromRequest();
		
		// convience variables
		$data = parent::getData();
		$r = $_REQUEST;	

		$content = $r[$data["name"]];		
		
		$this->setElementDataString( $content );
	}		
}

?>